package controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import pojo.EasyUiDataGridResult;
import pojo.TaotaoResult;
import pojo.TbItem;
import service.ItemService;

import javax.annotation.Resource;

@Controller
public class ItemController {

    @Resource
    ItemService itemService;

    /**
     * 商品列表查询
     *
     * @param page
     * @param rows
     * @return
     */
    @RequestMapping("/item/list")
    @ResponseBody
    public EasyUiDataGridResult showItemList(int page, int rows) {
        //调用service，获取商品列表
        EasyUiDataGridResult easyUiDataGridResult = itemService.getTbItemList(page, rows);
        return easyUiDataGridResult;
    }

    /**
     * 商品添加
     *
     * @param tbItem
     * @return
     */
    @RequestMapping("/item/save")
    @ResponseBody
    public TaotaoResult createItem(TbItem tbItem) {
        //调用service，添加商品
        TaotaoResult taotaoResult = itemService.createItem(tbItem);
        return taotaoResult;
    }
}
